import java.time.LocalTime;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.ZonedDateTime;
import java.time.ZoneId;

public class timeTest {
    public static void main(String[] args) {
        long time = System.currentTimeMillis();
        System.out.println(time);

        LocalDate time1 = LocalDate.now();
        System.out.println(time1);

        LocalTime time2 = LocalTime.now();
        System.out.println(time2);

        // 格式话时间，常用的就是年月日和时分秒，注意大小写，H和h不一样，一个是24小时制，一个是12小时制
        LocalDateTime time3 = LocalDateTime.now();
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        String timeFormat = time3.format(formatter);
        System.out.println(timeFormat);

        // UTC时间处理
        ZonedDateTime time4 = ZonedDateTime.now(ZoneId.of("UTC"));
        System.out.println(time4);
    }
}
